/**
 * @CheckMetadata.as
 * 
 * @author sodaChen mail:asframe@163.com
 * @version 1.0
 * <br>Copyright (C), 2010 asFrame.com
 * <br>This program is protected by copyright laws.
 * <br>Program Name:AStruts2
 * <br>Date:2012-5-9
 */
package com.asframe.astruts2.metadata
{
	import com.asframe.ref.Metadata;
	import com.asframe.ref.Method;
	import com.asframe.ref.Type;
	import com.asframe.ref.Variable;
	import com.asframe.slf4j.ILogger;
	import com.asframe.slf4j.LoggerFactory;

	/**
	 * 检测AStruts2使用到的相关标签是否被支持
	 * @author sodaChen
	 * @Date:2012-5-9
	 */
	[Mediator]
	[View]
	public class CheckMetadata
	{
		private static var log			:ILogger = LoggerFactory.getLogger(CheckMetadata);
		[Ref]
		public var name					:String = "soda";
		
		public function CheckMetadata()
		{
			var type:Type = Type.forClass(CheckMetadata);
			check(type.getMetadata(MetadataConst.MEDIATOR_METADATA),MetadataConst.MEDIATOR_METADATA);
			check(type.getMetadata(MetadataConst.VIEW_METADATA),MetadataConst.VIEW_METADATA);
			//属性
			var variable:Variable = type.getVariable("name");
			check(variable.getMetadata(MetadataConst.REF_METADATA),MetadataConst.REF_METADATA);
			//方法
			var method:Method = type.getMethod("noticeMethod");
			check(method.getMetadata(MetadataConst.NOTICE_METADATA),MetadataConst.NOTICE_METADATA);
		}
		private function check(metadata:Metadata,msg:String):void
		{
			if(metadata == null)
			{
				log.error("AStuts2的" + msg + "元数据标签不被支持，请在编译器参数设置里设置支持相关的元数据标签编译");
			}
		}
		[Notice]
		public function noticeMethod():void
		{
			
		}
	}
}
